-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ch/psestimate memory #91
base: master
Are you sure you want to change the base?
Conversation
Hey @jrs65! I added Tristan and Simon to the review. Simon is probably most familiar next to you with the Fisher estimation code, and Tristan is just a really good code reviewer. Let me know if there is someone else I could add to help with this. I would like to get this going and merged! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me! (However, I'm not an expert code reviewer like @jrs65 and @tristpinsm , so it might be a good idea to have one of them skim through it before the final merge.)
My comments are all minor, and should be easily resolvable.
return recv_buffer | ||
|
||
def split_single(self, m, size): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docstring would be useful here, to describe in words what this function does
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Need feedback if it is comprehensible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why use this routine instead of mpiutil.partition_list()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want every rank to work with one m-mode, with partition list it's not guaranteed that i-th partition will have be length = size, where size is the number of total MPI processes running.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I think you could accomplish this with
mpiutil.partition_list(
np.range(self.telescope.mmax + 1), mpiutil.rank, (self.telescope.mmax + 1) // size
)
or something similar. However, if your code works, I'm not sure if it's worth the effort to change it...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking good, I'm glad to be finally getting this one merged.
I left a few comments, I'll have a look again when the current round of Simon's suggestions and my own are addressed. Does this actually run though? It seems like there's a few things which just shouldn't actually work.
else: | ||
y0 = x0 | ||
y2 = x2 | ||
|
||
return x2, y2 | ||
|
||
def q_estimator(self, mi, vec1, vec2=None, noise=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that you have an entirely new implementation of q_estimator
in your new class, why does the old one need to get changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to factor out the part of the code that projects from KL-basis to sky basis so that it can be reused as a method in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and the new PS-code would get just like a big spaghetti code. Tried to factor out as much as I could.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, makes sense to me
Yeah it's been running for half a year now... |
I did the changes you requested. @sjforeman @jrs65. I will run the code now and blacken before I commit and push the branch to git. |
40435ab
to
9f71ec6
Compare
This pull request introduces 3 alerts and fixes 1 when merging 9f71ec6 into 94f0ece - view on LGTM.com new alerts:
fixed alerts:
|
a9a76a2
to
c72303e
Compare
drift/core/psmc.py
Outdated
if mi < (self.telescope.mmax + 1): | ||
self.q_estimator(mi, vec1) | ||
|
||
# TO DO: Calculate q_a for noise power (x0^H N x0 = |x0|^2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added her a TODO item - at the moment we have no capability of simulating a noise bias.
On a note:
- the original psestimation code doesn't estimate a noise bias for a auto power spectrum (why?)
- Is x0^2 (=normalized KL-modes) supposed to be the noise bias? According to the m-mode paper see equation (91) - I thought you need to sandwich the estimator between realizations of white noise to get b_a.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh yeah, and the only that noise is set to True is in the Crosspower class and there it should be zero, so I don't see the point why it's even calculated?!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment to self and anyone else reading: We won't save noise in KL-basis to q-estimator. IMO it really doesn't need to be there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused by these comments. Isn't the noise bias estimated by the combination of fisher_bias
and gen_sample
?
I guess the problem is that the noiseonly
argument isn't set to True
when zero_mean == False
which it should be?
drift/core/psmc.py
Outdated
axis=0, | ||
).astype(np.float64) | ||
|
||
def noise_bias(self, mi, vec1, vec2=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this method for the future, in case we ever want to have a routine to calculate what Richard called the noise bias.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Scrap that. I don't think we need it.
request.Wait() | ||
|
||
# Fill recv buffer with messages | ||
recv_buffer[slc] = bi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh yeah, I have been getting a warning that this should be recv_buffer[tuple(slc)] instead of recv_buffer[slc]. Any opinions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, this is the most up to date PR for the multi parallelized Fisher code. It is ready for a second round. I left some comments concerning calculating a noise bias.
The new code as it is works at the moment only for
- auto correlation Fisher errors
- when no noise bias is calculated (but neither did the old psestimation code.)
Oh - and for some reason the black check is failing right now even though I reformatted the files with black - so I am not sure whats going on there. |
This pull request fixes 2 alerts when merging c72303e into 94f0ece - view on LGTM.com fixed alerts:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a few minor comments, but I will punt some of the more technical points to @jrs65
else: | ||
y0 = x0 | ||
y2 = x2 | ||
|
||
return x2, y2 | ||
|
||
def q_estimator(self, mi, vec1, vec2=None, noise=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, makes sense to me
drift/core/psmc.py
Outdated
@@ -81,7 +85,7 @@ def _work_fisher_bias_m(self, mi): | |||
x = self.gen_sample(mi, n) | |||
qa[:, s:e] = self.q_estimator(mi, x) | |||
|
|||
ft = np.cov(qa) | |||
# ft = np.cov(qa) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this could be removed completely
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, I will get rid of it... I just kept it because it was Richard's comments.
return recv_buffer | ||
|
||
def split_single(self, m, size): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why use this routine instead of mpiutil.partition_list()
?
@cahofer it looks like there's a few more comments being worked on in here, is that right? |
def q_estimator(self, mi, vec1, vec2=None, noise=False): | ||
"""Estimate the q-parameters from given data (see paper). | ||
|
||
def project_vector_kl_to_sky(self, mi, vec1): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as before: should this go in drift.core.kltransform
instead of drift.core.psestimation
?
Monte Carlo Fisher matrix estimation for m-mode formalism for large telescope classes.
a class that estimates the Fisher matrix with Monte Carlo simulations when memory demand is high. Features:
issues.
receives one m-mode at at time.
rank. As such, each rank with a sub range of bands is subject to every m-mode.
distributed MPIArray over bands